
#pragma once
#include "ly/box.hpp"
#include "ly/export.hpp"
#include "ly/types.hpp"
#include "ly/vec2.hpp"

namespace ly {

template <class C>
class LY_API polygon {
 public:
  typedef std::vector<ly::point<C>> points_t;
  typedef ly::box<C> box_t;

  polygon(const points_t& pts) : m_points(pts) {}
  polygon() = default;

  C area() const { return C(0); };
  void box() const {};

  void points(const points_t& pts) { m_points = pts; }
  points_t points() const { return m_points; }

 private:
  points_t m_points;
  box_t m_box;
};

/**
 * @brief Represents a polygon with holes (external boundary and internal holes)
 * 
 * This structure defines a polygon that consists of an external boundary and 
 * potentially multiple internal holes. The outer boundary and inner holes are 
 * represented as separate point sequences in the `points_arr` vector.
 * 
 * - The first element `points_arr[0]` represents the external boundary of the polygon
 * - Subsequent elements `points_arr[1]`, `points_arr[2]`, etc. represent internal holes
 * 
 * @tparam C Coordinate type (e.g., Coord, DCoord)
 */
template <class C>
struct LY_API polygon_hole {
 public:
  typedef std::vector<point<C>> points_t;
  typedef std::vector<points_t> points_vec_t;

  polygon_hole(const points_vec_t& pts) : m_points_vec(pts) {}
  polygon_hole() = default;

  /**
   * @brief Calculate the area of the polygon
   * @return C Area value (currently returns zero - placeholder implementation)
   */
  C area() const { return C(0); };

  /**
   * @brief Calculate bounding box of the polygon
   */
  void box() const {};

 private:
  points_vec_t m_points_vec;
};

typedef polygon<Coord> Polygon;
typedef std::vector<polygon<Coord>> Polygons;

typedef polygon<DCoord> DPolygon;
typedef std::vector<polygon<DCoord>> DPolygons;

typedef polygon_hole<Coord> PolygonHole;
typedef std::vector<polygon_hole<Coord>> PolygonHoles;

typedef polygon_hole<DCoord> DPolygonHull;
typedef std::vector<polygon_hole<DCoord>> DPolygonHoles;

}  // namespace ly
